<template>
    <div class="tableDiv">
        <el-collapse v-model="historyactiveName" accordion>
            <el-collapse-item
              v-for="(item, index) in treatmentRecordDataList" :key="index" :name="index">
              <template slot="title">
                <div style="width: 100%;
                overflow: hidden;
                text-overflow: ellipsis;
                white-space: nowrap;">
               治疗日期：{{parseTime(item.treatmentTime)}}  治疗部位：<span style="color:red;font-size:15px;font-weight:700;margin-right:8px;">{{item.treatmentPlace}}</span> 治疗项目：<span style="color:red;font-size:15px;font-weight:700;">{{item.packageContent}}</span>
              </div>
              </template>
              <el-row style="font-size:15px">
                <el-col :span="6">顾客编号:{{ item.visitNum }}</el-col>
                <el-col :span="3">顾客ID:{{ item.patientId }}</el-col>
                <el-col :span="3">手机:{{ item.patientPhone }}</el-col>
                <el-col :span="3">状态:{{ matchDict("sys_diagnosis_status", item.status) }}</el-col>
                <el-col :span="3">卡号:{{ item.cardNumber }}</el-col>
                <el-col :span="3">顾客分类:{{ matchDict("sys_patient_sort", item.customerSort) }}</el-col>
                <el-col :span="3">皮肤色度:{{ matchDict("sys_skin_tone", item.tone) }}</el-col>
              </el-row>
              <el-row style="font-size:15px">
                <el-col :span="6">患者地址:{{ item.area }}</el-col>
                <el-col :span="6">详细地址:{{ item.address }}</el-col>
                <el-col :span="3">顾客性质:{{ matchDict("sys_patient_properties", item.properties) }}</el-col>
                <el-col :span="3">职业:{{ item.job }}</el-col>
                <el-col :span="3">微信号:{{ item.wxNum }}</el-col>
  
              </el-row>
              <el-row style="font-size:15px">
                <el-col :span="24">就诊门诊:<span style="font-size:15px;font-weight:700;">{{ item.deptName }}</span></el-col>
            </el-row>
              <el-row style="font-size:15px">
                <el-col :span="24">医生诊断:<span style="font-size:15px;font-weight:700;">{{ item.doctorDiagnosis
                }}</span></el-col>
              </el-row>
              <el-row style="font-size:15px">
                <el-col :span="24">医生方案:<span style="font-size:15px;font-weight:700;">{{ item.doctorPlan}}</span></el-col>
              </el-row>
              <el-row style="font-size:15px">
                <el-col :span="24">治疗项目:<span style="color:red;font-size:15px;font-weight:700;">{{ item.packageContent }}</span></el-col>
              </el-row>
              <el-row style="font-size:15px">
                <el-col :span="24">治疗参数:<span style="color:red;font-size:15px;font-weight:700;">{{ item.remark }}</span></el-col>
              </el-row>
              <el-row style="font-size:15px">
                <el-col :span="6">治疗部位:<span style="color:red;font-size:15px;font-weight:700;">{{ item.treatmentPlace }} </span></el-col>
                <el-col :span="6">治疗反应:<span style="color:red;font-size:15px;font-weight:700;">{{ getTreatmentReactionText(item.treatmentReaction) }}</span></el-col>
              
                <el-col :span="6">治疗效果:<span style="color:red;font-size:15px;font-weight:700;">{{ matchDict("sys_treatment_effect", item.treatmentEffect) }} </span></el-col>
              
                <el-col :span="6">治疗价格:<span style="color:red;font-size:15px;font-weight:700;">{{ item.treatmentPrice }} </span></el-col>
              </el-row>
              <el-row style="font-size:15px">
                <el-col :span="6">治疗医生:{{ item.treatmentDoctorName }}</el-col>
                <el-col :span="6">治疗时间:{{parseTime(item.treatmentTime ) }}</el-col>
                <el-col :span="6">方案总额:{{ item.doctorTotalExpenses }}</el-col>
                <el-col :span="6">治疗费用:{{ item.doctorTreatmentExpenses }}</el-col>
              </el-row>
           
              <el-row style="font-size:15px;float:right">
                <el-button size="mini" @click="addRecord(item)" type="primary"
                  style="margin-left:15px;margin-bottom:10px;" :disabled="item.packageContent==currentItem ? false : true">引用记录</el-button>
              </el-row>
            </el-collapse-item>
          </el-collapse>
    </div>
  </template>
  
  <script>
  import store from "@/store";
  import { getTreatmentList } from "@/api/treatmentWorkstation/treatmentManagement";
  export default {
    name: "treatmentHistory",
    components: {},
    props: ["basicInfo","currentItem"],
    dicts: ['sys_diagnosis_status',
      'sys_user_sex', "photo_upload_type",
      "photo_lighting_type",
      "sys_face_part",
      "sys_patient_properties",
      "sys_skin_tone", "sys_patient_sort",
      'sys_treatment_reaction', 'sys_treatment_effect'],
    data() {
      return {
        historyactiveName:0,
        treatmentRecordDataList: [],
        treatmentRecordQueryParams: {
          pageNum: 1,
          pageSize: 9999,
          visitNum: '',
          patientId: '',
        },
        treatmentRecordTotal: 0,
      };
    },
    created() {
  
    },
    mounted() {
      console.log(this.basicInfo)
      if (this.basicInfo) {
        this.treatmentRecordQueryParams.patientId = this.basicInfo.patientId
        this.getTreatmentList()
      }
  
    },
    methods: {
          /** id转化成对应的文字 */
    matchDict: function (key, id) {
      let _this = this;
      const result = _this.dict.type[key];
      let textValue = "";
      result.forEach((item) => {
        if (item.raw.dictValue == id) {
          textValue = item.raw.dictLabel;
        }
      });
      return textValue;
    },
    addRecord(data){
      this.$emit('comfirmCitate',data)
    },
          //获取诊断状态字典值对应的label
    getDiagnosisStatusLabel(status) {
      let label = ''
      this.dict.type.sys_diagnosis_status.forEach((item) => {
        if (item.value == status) {
          label = item.label
        }
      })
      return label

    },
      getTreatmentReactionText(value) {
        let text = ''
        if (value.includes(',')) {
          let data = value.split(',')
          data.forEach((item, index) => {
            this.dict.type.sys_treatment_reaction.forEach((row) => {
              if (item === row.value) {
                if (index + 1 < data.length) {
                  text = `${text + row.label},`
                } else {
                  text += row.label
                }
              }
            })
          })
        } else {
          this.dict.type.sys_treatment_reaction.forEach((row) => {
            if (value === row.value) {
              text = row.label
            }
          })
        }
        return text
      },

      // 获取顾客治疗列表
      getTreatmentList() {
        getTreatmentList(this.treatmentRecordQueryParams).then(
          (response) => {
            if (response.code == 200) {
              this.treatmentRecordDataList = response.rows;
              this.treatmentRecordTotal = response.total
            } else {
              this.$modal.msgError(response.msg);
            }
  
          }
        )
      },
      
  
    },
  };
  </script>
  <style scoped lang="scss">
  .tableDiv {
    
  }
  </style>
  